{include file="public/header"}
<style>
    .config-item > div {
        height: 254px;
        border-radius: 20px;
        background: linear-gradient(rgb(186, 240, 221) 0%, rgb(81, 188, 153) 100%);
        position: relative;
        color: #fff;
        transition: all 0.2s;
    }
    .config-item > div > div:nth-child(1) {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        padding-top: 30px;
        margin-left: 25px;
    }
    .config-item > div > div:nth-child(2) {
        font-size: 22px;
        margin-top: 28px;
        margin-left: 25px;
    }
    .config-item > div > div:nth-child(3) {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.8);
        margin-top: 14px;
        margin-left: 25px;
    }
    .config-item > div > div:nth-child(4) {
        font-size: 14px;
        max-width: 170px;
        margin-top: 26px;
        margin-left: 25px;
    }
    .config-item > div > div:nth-child(5) > a {
        position: absolute;
        background: rgb(219, 226, 246);
        color: rgb(19, 152, 108);
        width: 98px;
        height: 40px;
        border-radius: 20px;
        font-size: 14px;
        cursor: pointer;
        line-height: 40px;
        text-align: center;
        right: 20px;
        bottom: 30px;
    }
    .config-item > div > div:nth-child(6) {
        width: 48px;
        height: 48px;
        background: #fff;
        border-radius: 50%;
        opacity: 0.5;
        position: absolute;
        left: 55px;
        top: 30px;
    }
    .config-item > div > div:nth-child(7) {
        width: 54px;
        height: 54px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 0px 34px;
        position: absolute;
        right: 57px;
        top: 0px;
    }
    .config-item > div > div:nth-child(8) {
        /* background: rgb(106, 202, 165); */
        background: linear-gradient(rgb(186, 240, 221) 0%, rgb(81, 188, 153) 100%);
        border-radius: 0px 35px;
        transform: matrix(-1, 0, 0, 1, 0, 0);
        width: 54px;
        height: 54px;
        position: absolute;
        right: 57px;
        top: 53px;
    }
    .config-item > div > div:nth-child(9) {
        background: rgba(255, 255, 255, 0.66);
        border-radius: 0px 34px;
        width: 54px;
        height: 54px;
        position: absolute;
        right: 57px;
        top: 106px;
    }
    .config-item > div > div:nth-child(10) {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 6px;
        transform: rotate(-45deg);
        position: absolute;
        right: 15px;
        top: 87px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

        </div>

        <div class="layui-card-body">
            <div class="config-item el-col el-col-24 el-col-xs-24 el-col-sm-12 el-col-md-8 el-col-lg-6"
                 style="padding: 16px 19px;">
                <div>
                    <div><img src="/static/admini/images/shopro-icon.png" alt=""></div>
                    <div>商城信息</div>
                    <div>配置商城基本信息</div>
                    <div>商城名称、H5域名、Logo</div>
                    <div><a class="layui-btn layuiadmin-btn-useradmin" data-type="setting_shop" href="javascript:;">立即设置</a></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__ADMIN__/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url($module . '/index')}"
            , method: 'Post'
            , limit: '{$pageSize}'
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.status, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
            , cols: [[
                {
                    field: 'id', title: 'ID', sort: true, align: 'center'
                }
                , {field: 'num', title: '期数', sort: true, align: 'center'}
                , {field: 'time', title: '日期', sort: true, align: 'center'}
                , {field: 'sum', title: '值', sort: true, align: 'center'}
                , {field: 'code', title: '开奖码', sort: true, align: 'center'}
                , {
                    field: 'status', title: '是否开奖', align: 'center', templet: function (d) {
                        if (d.status == 1) {
                            return '已开奖';
                        } else {
                            return '未开奖';
                        }
                    }
                }
                // , {field: 'poster', minWidth: 50, title: '封面', align: 'center', templet: '<div><img width="100" src="{{d.poster}}" /></div>'}
                // , {field: 'annex_txt', title: 'TXT地址', sort: true}
                // , {field: 'annex_zip', title: 'ZIP地址', sort: true}
                // , {field: 'download_num', title: '下载次数', sort: true}
                // , {
                //     field: 'rec', title: '是否推荐', align: 'center', templet: function (d) {
                //         if (d.rec == 1) {
                //             return '<div><input type="checkbox" value="' + d._id.$oid + '" checked name="rec" lay-skin="switch" lay-text="推荐|否" lay-filter="rec"></div>';
                //         } else {
                //             return '<div><input type="checkbox" value="' + d._id.$oid + '" name="rec" lay-skin="switch" lay-text="推荐|否" lay-filter="rec"></div>'
                //         }
                //     }
                // }
                // , {field: 'status', title: '是否上架', sort: true}
                , {fixed: 'right', title: '操作', toolbar: '#table-useradmin-webuser', width: 200}
            ]]
            , page: true
        });

        //监听行工具事件
        table.on('tool(LAY-user-manage)', function (obj) {
            var data = obj.data;
            // console.log(obj)
            if (obj.event === 'del') {
                console.log(obj);
                layer.confirm('真的删除行么', function (index) {
                    $.ajax({
                        url: "{php echo $this->createWebUrl('del');}",
                        data: {
                            id: obj.data.id,
                            table: '{$module}'
                        },
                        type: "Post",
                        dataType: "json",
                        success: function (data) {
                            console.log(data);
                            if (data.status) {
                                layer.msg(data.msg);
                                // location.reload(); //删除成功后再刷新
                                layer.close(index); //关闭弹层
                                table.reload('LAY-user-manage'); //数据刷新
                            } else {
                                layer.msg(data.msg);
                            }

                            // location.reload(); //删除成功后再刷新
                            // layer.close(index); //关闭弹层
                        },
                        error: function (data) {
                            $.messager.alert('错误', data.msg);
                        }
                    });
                    // obj.del();
                    // layer.close(index);
                });
            } else if (obj.event === 'edit') {
                var i = layer.open({
                    type: 2
                    , title: '更新'
                    , content: "{:url($module . '/edit')}&id=" + data.id
                    , maxmin: true
                    , area: ['500px', '450px']
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        console.log(2);

                        var iframeWindow = window['layui-layer-iframe' + index]
                            , submitID = 'LAY-user-front-submit'
                            , submit = layero.find('iframe').contents().find('#' + submitID);

                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {

                            var field = data.field; //获取提交的字段
                            console.log(field);
                            //提交 Ajax 成功后，静态更新表格中的数据
                            $.ajax({
                                url: "{:url($module . '/edit')}",
                                data: field,
                                type: "Post",
                                dataType: "json",
                                success: function (data) {
                                    console.log(data);
                                    if (data.status) {
                                        layer.msg(data.msg);
                                        // location.reload(); //删除成功后再刷新
                                        layer.close(index); //关闭弹层
                                        table.reload('LAY-user-manage'); //数据刷新
                                    } else {
                                        layer.msg(data.msg);
                                    }

                                    // location.reload(); //删除成功后再刷新
                                    // layer.close(index); //关闭弹层
                                },
                                error: function (data) {
                                    $.messager.alert('错误', data.msg);
                                }
                            });
                            // table.reload('LAY-user-manage'); //数据刷新

                        });

                        submit.trigger('click');
                    }
                });
                layer.full(i);

                // layer.prompt({
                //     formType: 2
                //     ,value: data.email
                // }, function(value, index){
                //     obj.update({
                //         email: value
                //     });
                //     layer.close(index);
                // });
            }
        });

        //事件
        var active = {
            batchdel: function () {
                var checkStatus = table.checkStatus('LAY-user-manage')
                    , checkData = checkStatus.data; //得到选中的数据

                if (checkData.length === 0) {
                    return layer.msg('请选择数据');
                }

                layer.prompt({
                    formType: 1
                    , title: '敏感操作，请验证口令'
                }, function (value, index) {
                    layer.close(index);

                    layer.confirm('确定删除吗？', function (index) {

                        //执行 Ajax 后重载
                        /*
                        admin.req({
                          url: 'xxx'
                          //,……
                        });
                        */
                        table.reload('LAY-user-manage');
                        layer.msg('已删除');
                    });
                });
            }
            , setting_shop: function () {
                var i = layer.open({
                    type: 2
                    , title: '更新'
                    , content: "{:url($module . '/setting_shop')}"
                    , maxmin: true
                    , area: ['500px', '450px']
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        console.log(2);

                        var iframeWindow = window['layui-layer-iframe' + index]
                            , submitID = 'LAY-user-front-submit'
                            , submit = layero.find('iframe').contents().find('#' + submitID);

                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                            console.log(data);
                            var field = data.field; //获取提交的字段
                            console.log(field);
                            //提交 Ajax 成功后，静态更新表格中的数据
                            $.ajax({
                                url: "{:url($module . '/setting_shop')}",
                                data: field,
                                type: "Post",
                                dataType: "json",
                                success: function (data) {
                                    console.log(data);
                                    if (data.status) {
                                        layer.msg(data.msg);
                                        // location.reload(); //删除成功后再刷新
                                        layer.close(index); //关闭弹层
                                        table.reload('LAY-user-manage'); //数据刷新
                                    } else {
                                        layer.msg(data.msg);
                                    }

                                    // location.reload(); //删除成功后再刷新
                                    // layer.close(index); //关闭弹层
                                },
                                error: function (data) {
                                    $.messager.alert('错误', data.msg);
                                }
                            });
                            // table.reload('LAY-user-manage'); //数据刷新

                        });

                        submit.trigger('click');
                    }
                });
                layer.full(i);
            }
        };

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;

            //执行重载
            table.reload('LAY-user-manage', {
                where: field
            });
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
{include file="public/footer"}
